package com.demo.controller;

import com.demo.entity.User;
import com.demo.intercept.Intercept;
import com.demo.vo.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * FileName: Controller
 *
 * @author: xunyong
 * Date:     2019/5/14 15:50
 * Description: 测试接口
 */
@RestController
@RequestMapping("spring")
@Api(description = "自定义注解 拦截器测试")
public class Controller {

    @RequestMapping(value = "say", method = RequestMethod.POST)
    public Map say(HttpServletRequest request, HttpServletResponse response) {
        Map map = new HashMap<>();
        map.put("name", "tiger");
        map.put("age", 25);
        return map;
    }

    @ApiOperation(value = "Test")
    @GetMapping(value = "user_info")
    @Intercept
    public Response<User> userInfo() {
        User user = new User();
        user.setAmount(new BigDecimal("0.2415"));
        user.setMoney(new BigDecimal("12.1200000"));
        user.setDete(new Date());
        return new Response<>(user);
    }

}